#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <set>
#include <vector>
using namespace std;

int main()
{
    set<int> s;
    vector<int> v;
    int n, tmp, repace;
    cin >> n;
    while (n--)
    {
        while (cin >> tmp)
        {
            v.push_back(tmp);
            if (s.count(tmp) == 0)
            {
                s.insert(tmp);
            }
            else
            {
                repace = tmp;
            }
            char ch = getchar();
            if (ch == '\n') break;
       }
 
    }
    int begin = *s.begin();
    set<int>::iterator it = s.begin();
    for (;it != s.end();it++)
    {
        if (*it == begin)
        {
            begin++;
        }
        else
        {
            cout << begin << " " << repace;
            return 0;
        }
    }
    return 0;
}
